//-------------------------------------------------------------------------
// Copyright (c) 2000-2009 Ufinity. All Rights Reserved.
//
// This software is the confidential and proprietary information of
// Ufinity
//
// Original author: xtliu
//
//-------------------------------------------------------------------------
// UFINITY MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
// THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE, OR NON-INFRINGEMENT. UFINITY SHALL NOT BE
// LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
// MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
//
// THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE
// CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE
// PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT
// NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT LIFE
// SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE
// SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE
// PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES"). UFINITY
// SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR
// HIGH RISK ACTIVITIES.
//-------------------------------------------------------------------------

package com.ufinity.estimation.service;

import java.util.List;

import com.ufinity.estimation.persistence.Pager;



/**
 * the database operator
 * 
 * <li> T：the Entity Object</li>
 * <li> K: the entity key Class</li>
 * 
 * @author xtliu
 * @version 1.0
 * @since Jun 15, 2009
 * @param <T>
 * @param <K>
 */
public interface BaseService<E, K> {
	/**
	 * 
	 * Delete Entity by Id
	 * 
	 * @since Jun 16, 2009
	 * @param id
	 *            the entity key
	 * @return Integer return 1 , if delete successful
	 */
	public Integer deleteEntity(K id);

	/**
	 * 
	 * Delete Entity by idList
	 * 
	 * @since Jun 16, 2009
	 * @param idList
	 *            the List of the entity key
	 * @return Integer the number of the deleting the entity
	 */
	public Integer deleteEntityByIdList(List<K> idList);

	
	public List<E> findAll();
	/**
	 * 
	 * Query the entities for Pagination
	 * 
	 * @since Jun 16, 2009
	 * @param currentPage current page number
	 * @return Pager<T> the Pager Object
	 */
	public Pager<E> findEntitiesPager(int currentPage);

	/**
	 * 
	 * Query the Entity by id
	 * 
	 * @since Jun 16, 2009
	 * @param id
	 *            the entity key
	 * @return T the Entity Object
	 */
	public E findEntityById(K id);

	/**
	 * 
	 * Query the Entity List by idList
	 * 
	 * @since Jun 16, 2009
	 * @param idList
	 *            the List of the entity key
	 * @return List<E> the Entity List
	 */
	public List<E> findEntityByIdList(List<K> idList);

	/**
	 * 
	 * Save Entity
	 * 
	 * @since Jun 16, 2009
	 * @param entity entity
	 * @return K the entity key if save successful
	 */
	public K saveEntity(E entity);

	/**
	 * 
	 * Update Entity
	 * 
	 * @since Jun 16, 2009
	 * @param entity entity will be updated
	 * @return Integer return 1 , if update successful
	 */
	public Integer updateEntity(E entity);
	
	
	public void saveOrUpdate(E entity);
}
